class Solution:
    def numJewelsInStones(self, J: str, S: str) -> int:
        count = 0
        diamond = {}
        for j in J:
            diamond[j] = j
        for s in S:
            if s in diamond:
                count += 1
        return count